<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width: initial-scale=1.0" />
    <title>Document</title>
    <script>
      function order(n) {
        n.sort(function (a, b) {
          if (a < b) {
            return -1; //表示 a 要排在 b 前面
          } else if (a > b) {
            return 1; //表示 a 要排在 b 后面
          } else {
            return 0; //表示 a 和 b 保持原样，不换位置
          }
        });
        return n;
      }
      function size(n) {
        var newArray = [];
        for (var i = 0; i < n.length; i++) {
          if (i == n.lastIndexOf(n[i])) {
            newArray.push(n[i]);
          }
        }
        console.log(order(newArray));
      }
      // var date = ["是", "是", "你", "哥", "哥", "谁"];
      var date = [1, 1, 1, 2, 2, 3, 4, 5, 6, 3, 4, 2, 4, 1];
      size(date);
    </script>
  </head>
  <body></body>
</html>
